package org.dudemonkey.jvm.concurrency.chp1dot3;

import org.dudemonkey.jvm.concurrency.util.PrintUtil;

/**
 * 2020-5-13
 * 简单了解synchronized 锁 共享变量。
 * 现在可以尝试去理解线程共享 安全与不安全的概念了
 */
public class TestWaitMain {
    public static final Object sharedObj =new Object();

    public static void main(String[] args) {
        SubThread st1 = new SubThread(sharedObj);
        st1.start();
        new Thread(()->{
                System.out.println(Thread.currentThread().getClass().getName()+"  "+ Thread.currentThread().getName());
//            PrintUtil.sleep(3);
                synchronized (sharedObj){
                    System.out.println("Catch lock , sleep 5 secs , do biz .");
//                    Thread.sleep(5*1000);
                    PrintUtil.sleep(5);
                }
        },"Biz Main Thread").start();


    }
}
